#pragma once
#include "RBTree.h"
namespace dzp
{
	template <class K,class V>
	class map
	{
		struct mapkeyofT
		{
			const K& operator()(const pair<K, V>& x)
			{
				return x.first;
			}
		};
	public:
		typedef typename RBTree<K, pair<K, V>, mapkeyofT>::iterator iterator;
		iterator begin()
		{
			return _t.begin();
		}
		iterator end()
		{
			return _t.end();
		}
		pair<iterator,bool> insert(const pair<K, V>& x)
		{
			return _t.insert(x);
		}
		V& operator[](const K& x)
		{
			pair<iterator,bool> it= _t.insert(dzp::make_pair(x,V()));
			return it.first->second;
		}
	private:
		RBTree<K, pair<K, V>, mapkeyofT> _t;
	};
}
